package handler

import (
	"time"
	"web_framework/model"
	"web_framework/pkg/constvar"
	"web_framework/service"
)

//4.3节207请求协议
type AppStorageOutNoticeHandle struct {
}

type responseData207 struct {
	Type       int    `json:"type,omitempty"`
	RouterName string `json:"routerName,omitempty"`
}

func (appStorageOutNoticeHandle AppStorageOutNoticeHandle) handleMsg(data model.Request, clientId string) (result model.Response) {

	routerName := service.GetRouterName(data.Data.Sn)

	var returnData interface{} = responseData207{
		Type:       data.Data.NoticeType,
		RouterName: routerName,
	}

	return model.Response{
		Mid:   data.Mid,
		Mtype: constvar.MTypeAppStorageNoticeRequest,
		Time:  time.Now().Unix(),
		Data:  &returnData,
	}
}
